﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace SRQIDT
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public static int TS_count;//任务段计数
        public static int FM_count;//失效模式计数
        public static int FR_count;//失效故障计数
        public static string TS_Name;//任务段名称
        
        //定义序列结构
        
        //任务段存储结构
        public class TaskSegment
        {
            public string TS_id;//任务段id
            public string TS_Name;//名字
            public double Excuse_Time;//执行时间
            public int FailureModeCount;//故障模式计数            
            public bool TS_isselected;//执行任务段时，是否选择标识//不再需要了。
            public bool TS_isdeleted;//标识，是否删除标识
        }
        public static TaskSegment[] TSA = new TaskSegment[1000];

        public class FailureMode
        {
            public string TS_Name;//任务段名称
            public string FM_id;//故障id
            public int Level;//故障级别
            public double Recovery_time;//恢复时间
            public double Probability;//发生概率
            public double FailureRate;//故障模式失效率
            public bool FM_isdeleted;//标识，是否删除标识
        }
        public static FailureMode[] FMA = new FailureMode[1000];

        public class FailureRecord
        {
            public string TS_Name;//任务段名称
            public string FM_id;//失效模式id
            public int FM_lv;//故障模式级别
            public double FMH_time;//失效发生时间            
            public double FMR_time;//故障恢复时间
        }
        public static FailureRecord[] FRA = new FailureRecord[10000];

        public class TaskProfile//任务剖面
        {
            public string TP_name;
            public double Profile_probability;//剖面概率 
            public int P_Task_count;
            public string[] TS_id = new string[1000];//剖面所含任务段
        }
        public static TaskProfile[] TPA = new TaskProfile[1000];

        //初始化不可见
        public void PanelVisibleInitialization()
        {
            new_TaskModeling.Visible = false;
            new_Certainty.Visible = false;
            new_Transform.Visible = false;
            new_Simulation.Visible = false;
        }

        //控件定义
        public static SRQIDT.functions.TaskModeling new_TaskModeling = new SRQIDT.functions.TaskModeling();
        public static SRQIDT.functions.Certainty new_Certainty = new SRQIDT.functions.Certainty();
        public static SRQIDT.functions.Transform new_Transform = new SRQIDT.functions.Transform();
        public static SRQIDT.functions.Simulation new_Simulation = new SRQIDT.functions.Simulation();
        
       
        //创建任务剖面
        private void CertaintyToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            SRQIDT.forms.NewTaskProfile NTP_form = new SRQIDT.forms.NewTaskProfile();
            NTP_form.Show();
        }

        //转移型任务剖面
        private void TransformToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            this.panel1.Controls.Add(new_Transform);
            PanelVisibleInitialization();
            new_Transform.Visible = true;
            this.Refresh();
        }
        //任务设置
        private void TaskSettingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SRQIDT.forms.TaskSetting NT_form = new SRQIDT.forms.TaskSetting();
            NT_form.Show();
        }
        //任务建模
        private void TaskModelingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.panel1.Controls.Add(new_TaskModeling);
            PanelVisibleInitialization();
            new_TaskModeling.Visible = true;
            this.Refresh();
        }
        //新建工程
        private void NewProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SRQIDT.forms.NewProject NP_form = new SRQIDT.forms.NewProject();
            NP_form.Show();
        }
        //仿真设置
        private void SimulationSettingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SRQIDT.forms.SimulationSetting SS_form = new SRQIDT.forms.SimulationSetting();
            SS_form.Show();
        }
        //仿真输出
        private void SimulationDisplayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.panel1.Controls.Add(new_Simulation);
            PanelVisibleInitialization();
            new_Simulation.Visible = true;
            this.Refresh();
        }

    }
}
